<template>
    <div>
        <el-form :rules="pasrules" ref="pasForm" :model="pwd" label-width="80px"
                 label-position="right">
            <el-form-item prop="password" label="密码">
                <el-input style="width: 250px" type="password" v-model="pwd.password"></el-input>
            </el-form-item>
            <el-form-item prop="repassword" label="确认密码">
                <el-input style="width: 250px" type="password" v-model="pwd.repassword"></el-input>
            </el-form-item>

            <div style="margin-left: 150px;">
                <el-button type="primary" @click="doUpdate">确认修改</el-button>
            </div>
        </el-form>
    </div>
</template>

<script>
    export default {
        name: "Password",
        data() {
            return {
                pwd: {
                    password: '123456789',
                    repassword: '123456789',
                },
                pasrules: {
                    password: [{required: true, message: '请输入密码', trigger: 'blur'}],
                    repassword: [{required: true, message: '请确认密码', trigger: 'blur'}],
                },
            }
        },
        methods: {
            doUpdate() {
                if (this.pwd.password && this.pwd.repassword && (this.pwd.password == this.pwd.repassword)) {
                    this.putRequest('/system/hr/password?password=' + this.pwd.password + '&repassword=' + this.pwd.repassword).then(resp => {
                        if (resp) {
                            window.sessionStorage.setItem("user", JSON.stringify(this.hr));
                        }
                    })
                } else {
                    this.$message({
                        type: 'info',
                        message: '两次输入密码不一样'
                    });
                }
            }
        }
    }
</script>

<style scoped>

</style>